<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>res_edit.html</title>
</head>
 <body>
 <script type="text/javascript">
 	var winResEdit = new Windows("res_edit");
 	var oResEdit = {
 		winSelIcon : new Windows("SelIcon"),
 		initForm : function(){
 			winResEdit.find("#resForm").form({
 				url:'$!basePath/admin/res/doEdit',
 				onSubmit: function(){
			    	var pass = winResEdit.find('#resForm').form("validate");
			    	if(pass){
			    		winResEdit.find("#ok").linkbutton("loading");
			    	}
			    	return pass; 
			    },   
			    success:function(data){
			   		var result = jQuery.parseJSON(data);   
			        if(result.success == true){
			        	top.Notiy.success("修改成功!");
			        	var jResult = new JSONObject();
			        	jResult.put("result","true");
			        	jResult.put("id","$!res.id");
			        	winResEdit.setReturnValue(jResult);
						winResEdit.close();
			        }else if(result.NoChanges){
			        	top.Notiy.info("您未做任何修改!");
			        	var jResult = new JSONObject();
			        	jResult.put("result","false");
			        	winResEdit.setReturnValue(jResult);
						winResEdit.close();
			        }else{
			        	top.Dialog.alert("错误",result.error,"error");
			        }
			        winResEdit.find("#ok").linkbutton("reset");
			    }
 			});
 		},
 		initWindows : function(){
 			oResEdit.winSelIcon.windows({
 				title:"选择图标",
				width:300,
				height:300,
				modal:false,
				closed:true,
				maximizable:true,
				iconCls:'icon-button',
				href:"$!basePath/admin/res/selIcon",
				onClose:function(){
					var result = JSONObject.parseJSON(oResEdit.winSelIcon.getReturnValue());
					if(result.success){
						var oInput = winResEdit.find("#resForm").find("input[name='icon']");
						oInput.val(result.iconCls);
					}
				}
 			});
 		},
 		ok : function(){
 			oResEdit.winSelIcon.close();
 			winResEdit.find('#resForm').submit();
 		},
 		cancel : function(){
 			oResEdit.winSelIcon.close();
 			winResEdit.close();
 		}
 	};
 	$(function(){
		oResEdit.initForm();
		oResEdit.initWindows();
		winResEdit.find("#btnSelIcon").click(function(){
			oResEdit.winSelIcon.open();
		});
 	});
 </script>
 <div class="easyui-layout" data-options="fit:true">
	 <div data-options="region:'center',border:false">
	 	<form id="resForm" method="post" style="padding-top:10px;padding-left:15px;">
	 		<input type="hidden" name="id" value="$!res.id"/>
			<table width="90%">
				<tr>
					<td>上级资源：</td>
					<td>
						<select id="parentRes" name="parentId" class="easyui-combotree" style="width: 193px;" data-options="url:'$!basePath/admin/res/resTree',animate:true">
							<option selected="selected" value="$!res.parentId">$!parentResName</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>资源名称：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="name" maxlength="50" data-options="required:true" style="width: 100%;" value="$!res.name"/>
					</td>
				</tr>
				<tr>
					<td>链接地址：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="url" maxlength="100" data-options="required:true" style="width: 100%;" value="$!res.url"/>
					</td>
				</tr>
				<tr>
					<td>图标/样式：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="icon" maxlength="50" data-options="required:true" style="width: 80%;" value="$!res.icon"/><a id="btnSelIcon" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"></a>
					</td>
				</tr>
				<tr>
					<td>描述：</td>
					<td>
						<textarea class="easyui-textarea" rows="5" cols="21" style="width:100%;" class="easyui-textarea" name="descript">$!res.descript</textarea>
					</td>
				</tr>
				<tr>
					<td>是否启用：</td>
					<td>
						<label>启用</label>
						<input type="radio" name="enabled" value="0" checked="checked"/>
						<label>不启用</label>
						<input type="radio" name="enabled" value="1"/>
						#setRadioValue("res_edit","enabled","$!res.enabled")
					</td>
				</tr>
			</table>
		</form>
	 </div>
	 <div data-options="region:'south',border:false">
	 	<div class="dialog-button">
			<a id="ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="oResEdit.ok()">确定</a>
			<a id="cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="oResEdit.cancel()">取消</a>
		</div>
	</div>
 </div>
  </body>
</html>
